package com.example.yuejian.fragment.club;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.yuejian.Adapter.CourseAdapter;
import com.example.yuejian.Bean.Course;
import com.example.yuejian.R;
import com.example.yuejian.listener.ClubListener;
import com.example.yuejian.model.CourseModel;

import java.util.List;


public class ClubCourseFragment extends Fragment implements ClubListener<Course> {
    View view;
    RecyclerView recyclerView_club_course;
    private int clubid;
    @Override
    public View onCreateView(LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState)
    {
        view = inflater.inflate(R.layout.fragment_club_course, null) ;
        initView();
        CourseModel courseModel = new CourseModel();
        courseModel.courseData(this,clubid);
        return view ;
    }


    private void initView(){
        recyclerView_club_course = (RecyclerView)view.findViewById(R.id.recyclerView_club_course);
        recyclerView_club_course.setLayoutManager(new LinearLayoutManager(getActivity()));
        Intent intent = getActivity().getIntent();
        Bundle bundle = intent.getExtras();
        clubid = bundle.getInt("clubid");

    }

    @Override
    public void onResponse(Course course) {
        List<Course.ClubcourselistBean> clubcourselistBeen = course.getClubcourselist();
        CourseAdapter adapter = new CourseAdapter(getActivity(),clubcourselistBeen);
        recyclerView_club_course.setAdapter(adapter);
    }

    @Override
    public void onFail(String msg) {

    }
}





